package com.vehicle.admin.web.common.shiro.token;

import com.vehicle.ucenter.api.entity.SysUser;
import org.apache.shiro.SecurityUtils;

/**
 * Created by yantingbin on 2017/7/18.
 */
public class TokenManager {
    public static SysUser getToken() {
        SysUser token = SecurityUtils.getSubject().getPrincipals().oneByType(SysUser.class);
        return token;
    }

    public static SysUser login(String username, String password) {
        ShiroToken token = new ShiroToken(username, password);

        SecurityUtils.getSubject().login(token);

        return getToken();
    }
}
